Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock when Stop and flush race #1430

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

prashantv
Copy link
Collaborator

Fixes #1428.

Stop signals the flush loop to end, but if the flush ticker has fired after we took the lock, then it tries to Sync, and waits for the same lock that Stop is holding. This causes a deadlock, as Stop holds the lock waiting for flush to end.

Fix by waiting for the flush loop to end outside of the critical section.

We only need to wait (and call Sync) if the write syncer has been initialized and stopped.

Fixes #1428.

Stop signals the flush loop to end, but if the flush ticker has fired
after we took the lock, then it tries to `Sync`, and waits for the same
lock that `Stop` is holding. This causes a deadlock, as `Stop` holds the
lock waiting for flush to end.

Fix by waiting for the flush loop to end outside of the critical
section.

We only need to wait (and call Sync) if the write syncer has been
initialized and stopped.
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.69%. Comparing base (b15585b) to head (3909ad7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1430      +/-   ##
==========================================
- Coverage   98.69%   98.69%   -0.01%     
==========================================
  Files          53       53              
  Lines        2997     2996       -1     
==========================================
- Hits         2958     2957       -1     
  Misses         31       31              
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@prashantv prashantv merged commit 3ffa0c0 into master Apr 13, 2024
9 checks passed
@prashantv prashantv deleted the prashant/stop-flush-race-deadlock branch April 13, 2024 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Deadlock when calling BufferedWriteSyncer.Stop
2 participants